home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8260 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  56 lines

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Type casting
  5. Date: Sat, 02 Mar 96 14:40:32 GMT
  6. Organization: none
  7. Message-ID: <825777632snz@genesis.demon.co.uk>
  8. References: <4gfnmi$gsc@calvin.risq.qc.ca> <4h5amm$dpv@umbc9.umbc.edu> <4h7oktINN433@anvil.ugrad.cs.ubc.ca>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4h7oktINN433@anvil.ugrad.cs.ubc.ca>
  15.            c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
  16.  
  17. >Incidentally, the only specific reference to undefined behavior in the context
  18. >of main() that I have been able to dig up in the Standard says that the exit
  19. >status of a program which doesn't provide a return value on exit from main() is
  20. >undefined. There is no discussion over T main() where T is not int, versus int
  21. >main().
  22.  
  23. 5.1.2.2.1 describes the behaviour of main when it is defined as
  24.  
  25.     int main(void)   { /*...*/ }
  26.  
  27. or
  28.  
  29.     int main(int argc, char *argv[]) { /*...*/ }
  30.  
  31. Some other forms can be shown to have the same behaviour as these from the
  32. rest of the standard (e.g. int main() or int main(int argc, char **argv) )
  33. but all of these forms return int. Nowhere does the standard define any
  34. behaviour for main returning a type other than int (or indeed most function
  35. declarations that do return int).
  36.  
  37. 3.16 undefined behaviour
  38.  
  39. "...
  40.  
  41.  If a ``shall'' or ``shall not'' requirement that appears outside of a
  42.  constraint is violated, the behaviour is undefined. Undefined behaviour
  43.  is otherwise indicated in this International Standard by the words
  44.  ``undefined behaviour'' ## or by the omission of any explicit definition
  45.  of behaviour. There is no difference in emphasis among these three; they
  46.  all describe ``behaviour that is undefined.''"
  47.  
  48. Note particularly everything after my ## mark. So void main() quite
  49. specifically invokes undefined behaviour according to the standard.
  50.  
  51. -- 
  52. -----------------------------------------
  53. Lawrence Kirby | fred@genesis.demon.co.uk
  54. Wilts, England | 70734.126@compuserve.com
  55. -----------------------------------------
  56.